	<include file='Common:header' />

		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">

			<!-- #section:basics/sidebar -->

	<include file='Common:left' />
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
					
							<div class="row maintop">
							<div class="col-xs-12 col-sm-1">
<!-- 点击模态框（Modal） -->
								<button class="btn btn-xs btn-danger" data-toggle="modal" data-target="#myModal">
									<i class="ace-icon fa fa-bolt bigger-110"></i>
										添加链接
								</button>
								
							</div>

								<div class="col-xs-12 col-sm-3">
								<form name="admin_list_sea" class="form-search" method="post" action="__URL__/plug_link_list">
									<div class="input-group">
										<span class="input-group-addon">
											<i class="ace-icon fa fa-check"></i>
										</span>
										<input type="text" name="val" id="val" class="form-control search-query admin_sea" value="{$val}" placeholder="输入链接名称或URL" />
										<span class="input-group-btn">
											<button type="submit" class="btn btn-xs  btn-purple">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
												搜索
											</button>
										</span>
									</div>
								</form>
								</div>
								  <div class="input-group-btn">
									<a href="__URL__/plug_link_list">
									<button type="button" class="btn btn-xs  btn-purple">
										<span class="ace-icon fa fa-globe icon-on-right bigger-110"></span>
										显示全部
									</button>
									</a>
								  </div>
							</div>

							<div class="row maintop">
								<div class="col-xs-12 col-sm-3">
								<a href="__URL__/plug_link_list">
									<button class="btn btn-xs btn-warning">
											返回列表
									</button>
								</a>
								<foreach name="link_type" item="v">
									<a href="__URL__/plug_link_list/type/{$v.plug_linktype_id}">
									<button class="btn btn-xs btn-warning">
											{$v.plug_linktype_name}
									</button>
									</a>
								</foreach>
									</div>
							</div>

		

							<div class="row">
							    <div class="col-xs-12">
										<div>
											<table width="100%" class="table table-striped table-bordered table-hover" id="dynamic-table">
												<thead>
													<tr>
													  <th width="6%">ID</th>
													  <th width="11%">链接名称</th>
													  <th width="27%">链接URL</th>
													  <th width="14%">联系QQ</th>
													  <th width="14%">所属栏目</th>
													  <th width="14%">添加时间</th>
													  <th width="8%" style="border-right:#CCC solid 1px;">状态</th>
													  <th width="6%" style="border-right:#CCC solid 1px;">操作</th>
												  </tr>
												</thead>

												<tbody>
                                                
                                                <foreach name="plug_link" item="v">
													<tr>
														<td height="28" >{$v.plug_link_id}</td>
														<td>{$v.plug_link_name}</td>
														<td><a href="{$v.plug_link_url}" target="_blank">{$v.plug_link_url}</a></td>
														<td>{$v.plug_link_qq}</td>
														<td>{$v.plug_linktype_name}</td>
														<td>{$v.plug_link_addtime|date='Y-m-d',###}</td>
														<td>
														<if condition='$v[plug_link_open] eq 1'>
														<a class="red" href="javascript:;" onclick="return stateyes({$v.plug_link_id});" title="已开启">
														<div id="zt{$v.plug_link_id}"><button class="btn btn-minier btn-yellow">状态开启</button></div>
														</a>
														<else/>
														<a class="red" href="javascript:;" onclick="return stateyes({$v.plug_link_id});" title="已禁用">
														<div id="zt{$v.plug_link_id}"><button class="btn btn-minier btn-danger">状态禁用</button></div>
														</a>														</if>														</td>
														<td>
															<div class="hidden-sm hidden-xs action-buttons">
																<a class="green"  href="javascript:;" onclick="return plug_link_edit({$v.plug_link_id});"  title="修改">
																	<i class="ace-icon fa fa-pencil bigger-130"></i>																</a>
																<a class="red" href="javascript:;" onclick="return del({$v.plug_link_id});" title="删除">
																	<i class="ace-icon fa fa-trash-o bigger-130"></i>																</a>															</div>														</td>
													</tr>
                                                 </foreach>   
                                                  <tr>
													  <td height="50" colspan="9" align="left">{$page}</td>
												  </tr>
												</tbody>
										  </table>
							    		</div>
									</div>
								</div>

<include file='Common:header_nav' />

					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

<!-- 显示模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form class="form-horizontal" name="plug_link_add" id="plug_link_add" method="post" action="__URL__/plug_link_runadd">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">×
            </button>
            <h4 class="modal-title" id="myModalLabel">
               添加友情链接
            </h4>
         </div>
         <div class="modal-body">
            
			
						<div class="row">
							<div class="col-xs-12">
								
                                	<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 所属栏目： </label>
										<div class="col-sm-10">
                                        <select name="plug_link_typeid"  class="col-sm-4 selector" >
                                        <option value="">请选择所属栏目</option>
                                        <foreach name="link_type" item="v">
                                        <option value="{$v.plug_linktype_id}">{$v.plug_linktype_name}</option>
                                        </foreach>
                                        </select>
                                        </div>
									</div>
									<div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 链接名称：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_name" id="plug_link_name" placeholder="输入链接名称" class="col-xs-10 col-sm-5" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>必须是以字母开头，数字、符号组合</span>
										</div>
									</div>
                                    <div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 链接URL：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_url" id="plug_link_url" placeholder="输入链接URL" class="col-xs-10 col-sm-8" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>必须是以http://开头</span>
										</div>
									</div>
                                    <div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 是否审核： </label>
										<div class="col-sm-10" style="padding-top:5px;">
                                            <input name="plug_link_open" id="plug_link_open" value="1" class="ace ace-switch ace-switch-4 btn-flat" type="checkbox" />
											<span class="lbl">&nbsp;&nbsp;默认关闭</span>
										</div>
									</div>
                                    <div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 联系站长：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_qq" id="plug_link_qq" placeholder="输入QQ或其他联系方式" class="col-xs-10 col-sm-5" />
										</div>
									</div>
                                    <div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 排序：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_order" id="plug_link_order" value="50" class="col-xs-10 col-sm-3" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>从小到大排序</span>
										</div>
									</div>
                                    <div class="space-4"></div>
									
								</div>
							</div>
			
			
			
			
         </div>
         <div class="modal-footer">
		 	<button type="submit" class="btn btn-primary">
            	提交保存
            </button>
		 	<button class="btn btn-info" type="reset">
				重置
			</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">
				关闭
            </button>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
   </form>
</div><!-- /.modal -->






<!-- 显示模态框（Modal） -->
<div class="modal fade in" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-backdrop fade in" id="gbbb" style="height: 100%;"></div>
<form class="form-horizontal" name="plug_link_runedit" id="plug_link_runedit" method="post" action="__URL__/plug_link_runedit">
<input type="hidden" name="plug_link_id" id="editplug_link_id" value="" />
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" id="gb"  data-dismiss="modal" 
               aria-hidden="true">×
            </button>
            <h4 class="modal-title" id="myModalLabel">
               修改友情链接
            </h4>
         </div>
         <div class="modal-body">
            
			
						<div class="row">
							<div class="col-xs-12">
								
                                	<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 所属栏目： </label>
										<div class="col-sm-10">
                                        <select name="plug_link_typeid" id="editplug_link_typeid"  class="col-sm-4" >
                                        <option value="">请选择所属栏目</option>
                                        <foreach name="link_type" item="v">
                                        <option value="{$v.plug_linktype_id}">{$v.plug_linktype_name}</option>
                                        </foreach>
                                        </select>
                                        </div>
									</div>
									<div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 链接名称：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_name" id="editplug_link_name" value="" class="col-xs-10 col-sm-5" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>必须是以字母开头，数字、符号组合</span>
										</div>
									</div>
                                    <div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 链接URL：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_url" id="editplug_link_url" value="" class="col-xs-10 col-sm-8" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>必须是以http://开头</span>
										</div>
									</div>
                                    <div class="space-4"></div>
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 联系站长：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_qq" id="editplug_link_qq" value="" placeholder="输入QQ或其他联系方式" class="col-xs-10 col-sm-5" />
										</div>
									</div>
                                    <div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 排序：  </label>
										<div class="col-sm-10">
											<input type="text" name="plug_link_order" id="editplug_link_order" value="" class="col-xs-10 col-sm-3" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>从小到大排序</span>
										</div>
									</div>
                                    <div class="space-4"></div>
									
								</div>
							</div>
			
			
			
			
         </div>
         <div class="modal-footer">
		 	<button type="submit" class="btn btn-primary">
            	提交保存
            </button>
            <button type="button" class="btn btn-default"  id="gbb" >
				关闭
            </button>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
   </form>
</div><!-- /.modal -->



<script>
function del(id,p){
	layer.confirm('你确定要删除吗？', {icon: 3}, function(index){
	layer.close(index);
	window.location.href="__URL__/plug_link_del/plug_link_id/"+id+"/p/"+p+"";
	});
}

function stateyes(val){
		  $.post('{:U("plug_link_state")}',
		  {x:val},
	function(data){
		if(data.status){
			if(data.info=='状态禁止'){
				var a='<button class="btn btn-minier btn-danger">状态禁用</button>'
				$('#zt'+val).html(a);
				return false;
			}else{
				var b='<button class="btn btn-minier btn-yellow">状态开启</button>'
				$('#zt'+val).html(b);
				return false;
			}
		}
	});
	return false;
}

//修改模态框状态
$(document).ready(function(){
	$("#myModaledit").hide();
	$("#gb").click(function(){
		$("#myModaledit").hide(200);
	});
	$("#gbb").click(function(){
		$("#myModaledit").hide(200);
	});
	$("#gbbb").click(function(){
		$("#myModaledit").hide(200);
	});
});

function plug_link_edit(val){
		  $.post('{:U("plug_link_edit")}',
		  {plug_link_id:val},
	function(data){
		if(data.status==1){
				$(document).ready(function(){
					$("#myModaledit").show(300);
					$("#editplug_link_id").val(data.plug_link_id);
					$("#editplug_link_name").val(data.plug_link_name);
					$("#editplug_link_url").val(data.plug_link_url);
					$("#editplug_link_qq").val(data.plug_link_qq);
					$("#editplug_link_order").val(data.plug_link_order);
					$("#editplug_link_typeid").val(data.plug_link_typeid);
				});
			}else{

		}
	});
	return false;
}


$(function(){
	$('#plug_link_add').ajaxForm({
		beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
		success: complete, // 这是提交后的方法
		dataType: 'json'
	});
	
	function checkForm(){
		if( '' == $(".selector").val()){
			layer.alert('链接所属栏目不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('.selector').focus(); 
			});
			return false;
		}
	
		if( '' == $.trim($('#plug_link_name').val())){
			layer.alert('友情链接名称不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#plug_link_name').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#plug_link_url').val())){
			layer.alert('友情链接URL不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#plug_link_url').focus(); 
			});
			return false;
		}
 }
	function complete(data){
		if(data.status==1){
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}else{
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
			return false;	
		}
	}
});


$(function(){
	$('#plug_link_runedit').ajaxForm({
		beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
		success: complete, // 这是提交后的方法
		dataType: 'json'
	});
	
	function checkForm(){
		if( '' == $("#editplug_link_typeid").val()){
			layer.alert('链接所属栏目不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#editplug_link_typeid').focus(); 
			});
			return false;
		}
	
		if( '' == $.trim($('#editplug_link_name').val())){
			layer.alert('友情链接名称不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#editplug_link_name').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#editplug_link_url').val())){
			layer.alert('友情链接URL不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#editplug_link_url').focus(); 
			});
			return false;
		}
 }
	function complete(data){
		if(data.status==1){
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}else{
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
			return false;	
		}
	}
 
});
</script>
	<include file='Common:footer' />
    
		</div><!-- /.main-container -->
	</body>
</html>
